package com.xjtu.platform.respondent.convert.impl;

import com.xjtu.platform.common.CurrentUser;
import com.xjtu.platform.common.Utils;
import com.xjtu.platform.respondent.convert.ConvertDto;
import com.xjtu.platform.respondent.convert.ConvertService;
import com.xjtu.platform.respondent.convert.dao.ConvertDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Map;

@Service
@Transactional
public class ConvertServieImpl implements ConvertService {

    @Resource
    private ConvertDao convertDao;

    @Override
    public Map<String, Object> getConvertList( CurrentUser currentUser ) {
        return Utils.getPage(currentUser ,()->convertDao.findConvertList(currentUser ));
    }

    @Override
    public void convertMoney(ConvertDto dto) {
        convertDao.setMoney(dto);
        convertDao.updateCredit(dto);
    }
}
